 //是否有权限显示 '操作' 列
    function isShowOperation() {
        return (p_edit != 'hidden' || p_delete != 'hidden');
    }
    var runlimit = {};
    //刷新
    function reload() {
    	runlimit.schconflict.reload();
    }
    //增加
    function add() {
    	runlimit.schconflict.add();
    }
    //编辑
    function edit(obj) {
    	runlimit.schconflict.edit(obj.getAttribute("id"));
    }
    //查看
    function view(id) {
    	runlimit.schconflict.view(id);
    }
    //删除
    function remove(obj) {
    	runlimit.schconflict.remove(obj.getAttribute("id"));
    }
runlimit.schconflict=(function(){
	var _pedit = null,
		_pdelete = null,
		prefix = "/conflict",
		_btnSearch = null,
		_exampleTable = null,
		_queryPcode = null,
		_conf = {
			
		},
		_init = function(p_edit,p_delete){
			_pedit = p_edit;
			_pdelete = p_delete;
			_btnSearch = $("#btn-search");
			_exampleTable = $('#exampleTable');
			_queryPcode = $("#query_pcode");
			_load();
	        _btnSearch.click(_search);
		},
		_search = function(){
        	_exampleTable.bootstrapTable('refresh');
        },
		_remove = function(id) {
	        layer.confirm('确定要删除选中的记录？', {
	            btn: ['确定', '取消']
	        }, function () {
	            $.ajax({
	                url: prefix + "/delete.do",
	                type: "post",
	                data: {
	                    'id': id
	                },
	                success: function (r) {
	                    if (r.code == 0) {
	                        layer.msg(r.msg);
	                        reload();
	                    } else {
	                        layer.msg(r.msg);
	                    }
	                }
	            });
	        })
	    },
		_view = function(id) {
	        layer.open({
	            type: 2,
	            title: '查看',
	            shadeClose: false, // 点击遮罩关闭层
	            area: ['500px', '400px'],
	            content: prefix + '/view.do?id=' + id
	        });
	    },
		_edit = function(id) {
	        layer.open({
	            type: 2,
	            title: '编辑',
	            shadeClose: false, // 点击遮罩关闭层
	            area: ['500px', '400px'],
	            content: prefix + '/edit.do?id=' + id
	        });
	    },
		_add = function() {
	        layer.open({
	            type: 2,
	            title: '新增',
	            shadeClose: false, // 点击遮罩关闭层
	            area: ['500px', '400px'],
	            content : prefix + '/add.do'
	        });
	    },
		_reload = function() {
	    	_queryPcode.val("");
	        _exampleTable.bootstrapTable('refresh');
	    },
		_load = function(){
			_exampleTable.bootstrapTable(
		            {
		                method: 'post',
		                url: prefix + "/list.do",
		                iconSize: 'outline',
		                toolbar: '#exampleToolbar',
		                striped: true,
		                dataType: "json",
		                pagination: true,
		                clickToSelect: true,
		                pageSize: 10,
		                pageNumber: 1,
		                showColumns: false,
		                sidePagination: "server",
		                paginationLoop: false,
		                contentType: "application/x-www-form-urlencoded",
		                queryParams: function (params) {
		                    return {
		                        pCode: _queryPcode.val(),
		                        limit: params.limit,
		                        offset: params.offset
		                    };
		                },
		                onClickRow:function(row, $element){
		                    $element.addClass('info').siblings().removeClass('info').end();
		                },
		               /* onDblClickRow: function (row, $element, field) {
		                    view(row.id);
		                },*/
		                columns: [
		                    {
		                        field: 'idx',
		                        formatter: orderFormatter,
		                        title: '序号',
		                        align: 'center',
		                        width: '40'
		                    },
		                    {
		                        field: 'userName',
		                        title: '飞行员'
		                    },
		                    {
		                        field: 'bmName',
		                        title: '任职岗级'
		                    },
		                    {
		                        field: 'userName1',
		                        title: '冲突人员'
		                    },
		                    {
		                        field: 'confInfo',
		                        title: '说明'
		                    },
		                    {
		                        title: '操作',
		                        align: 'center',
		                        visible: isShowOperation(),
		                        formatter: function (value, row, index) {
		                            return [
		                                '<a class="' + _pedit + '" href="#" title="编辑" id="' + row.id + '" onclick="edit(this)">',
		                                '<i class="glyphicon glyphicon-edit"></i>',
		                                '</a>&nbsp;&nbsp;',
		                                '<a class="' + _pdelete + '" href="#" title="删除" id="' + row.id + '" onclick="remove(this)">',
		                                '<i class="glyphicon glyphicon-remove  text-danger"></i>',
		                                '</a>&nbsp;&nbsp;'
		                            ].join('');
		                        }
		                    }]
		            })
		};
	
	
	return {
		init:function(p_edit,p_delete){
			_init(p_edit,p_delete);
		},
		add:function(){
			_add();
		},
		reload:function(){
			_reload();
		},
		edit:function(id){
			_edit(id);
		},
		view:function(id){
			_view(id);
		},
		remove:function(id){
			_remove(id);
		}
	};
})();